/**
 *
 */
package com.example.demo2.enums;

/**
 * @author thomas
 * @ClassName: ResponseCode

 * @date Oct 9, 2019 4:03:55 PM
 */
public enum ResponseCode {

  /** 操作成功 */
  RESPONSE_RETURN_CODE_SUCCESS("200", "success"),
  /** token校验失败 */
  RESPONSE_CODE_NO_PERMISSION("403", "token校验失败"),
  /** token为空 */
  RESPONSE_CODE_TOKEN_EMPTY("404", "token为空"),
  /** 系统异常 */
  RESPONSE_CODE_SYSTEM_ERROR("500", "系统异常"),
  /** 验签失败 */
  RESPONSE_RETURN_CODE_SIGN_VERIFICATION_ERROR("510", "验签失败"),
  /** 解密失败 */
  RESPONSE_RETURN_CODE_DECRYPT_ERROR("520", "解密失败"),
  /** 解密失败 */
  RESPONSE_GET_TOKEN_ERROR("530", "获取Token失败"),
  ;

  // status code
  private String code;
  // response msg
  private String message;

  private ResponseCode(String code, String message) {
    this.code = code;
    this.message = message;
  }

  public String getCode() {
    return code;
  }

  public String getMessage() {
    return message;
  }

  public static ResponseCode getResponseByCode(String code) {
    for (ResponseCode eCode :ResponseCode
        .values()) {
      if (eCode.getCode().equals(code)) {
        return eCode;
      }
    }
    return null;
  }

}
